var uerMsg = orderLogin()
var lmsg = new Vue({
	el: "#Luser",
	data: {
		info: uerMsg
	},
	methods: {
		getTel(item) {
			return item
		},
		getUid(item) {

			return item
		},
		getImgUrl(item) {
			var url = 'http://114.55.145.243:8080/img/img/' + item + '.jpg'
			return url
		},
		getUserClass(item) {
			if(item == "女")
				return 'gender famale';
			if(item == "男")
				return 'gender male';
		}
	}
})
var lmsg1 = new Vue({
	el: "#Luser1",
	data: {
		info: uerMsg
	},
	methods: {
		getTel(item) {
			return item
		},
		getUid(item) {

			return item
		},
		getImgUrl(item) {
			var url = 'http://114.55.145.243:8080/img/img/' + item + '.jpg'
			return url
		},
		getUserClass(item) {
			if(item == "女")
				return 'gender famale';
			if(item == "男")
				return 'gender male';
		}
	}
})

var hty = new Vue({
	el: "#did",
	data: {
		dlist: getOrder(),
		glist:getGuiOrder()
	},
	methods: {
		getToghref(item, item1, item2, item3, item4, item5) {

			var url = 'member_order_detail.html?orddl_pid=' + item + "&gui_name=" + item1 + "&order_price=" + item2 + "&order_sdate=" + item3 + "&order_edate=" + item4 + "&count=" + item5;
			//						var url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token=' + token + '&media_id=' + item;
			return url;
		},
		getStatus(item,index) {
			if(item == 1){
				return "等待导游接受 "
			}
			if(item == 3){
				return "导游已接受"
			}
			if(item == 4)
				return "服务已被拒绝"
		},
		getGuiStatus(item,index){
			if(item == 1)
				return "等待接受 "
			if(item == 3){
				return "服务已结束"
			}
			if(item == 4){
				return "服务已被拒绝"
			}
		},
		userDeleteOrder(id) {
			if(confirm("确认取消？")){
				$("#userOrder").html("")
				$.ajax({
				url: "http://114.55.145.243:8080/liantu/OrderServlet/userDeleteOrder",
				//url:"http://localhost:8080/javaproject/Login",
				async: false,
				data:{"order_id":id},
				xhrFields: {
					withCredentials: true
				},
				success: function(data) {
					if(data.status) {
						 location.href="#"
					}
				},
				dataType: "json"
			})
			}
		},
		guideReciveOrder(id){
			$.ajax({
				url: "http://114.55.145.243:8080/liantu/OrderServlet/guideRecevieOrder",
				//url:"http://localhost:8080/javaproject/Login",
				async: false,
				data:{"order_id":id},
				xhrFields: {
					withCredentials: true
				},
				success: function(data) {
					if(data.status) {
						 location.href="mamber_order.html"
					}
				},
				dataType: "json"
			})
		},
		guideRefuseOrder(id){
			$.ajax({
				url: "http://114.55.145.243:8080/liantu/OrderServlet/guideRefuseOrder",
				//url:"http://localhost:8080/javaproject/Login",
				async: false,
				data:{"order_id":id},
				xhrFields: {
					withCredentials: true
				},
				success: function(data) {
					if(data.status) {
						 location.href="#"
					}
				},
				dataType: "json"
			})
		},
		guideDeleteOrder(id) {
			if(confirm("确认删除？")){
				$("#userOrder").html("")
				$.ajax({
				url: "http://114.55.145.243:8080/liantu/OrderServlet/userDeleteOrder",
				//url:"http://localhost:8080/javaproject/Login",
				async: false,
				data:{"order_id":id},
				xhrFields: {
					withCredentials: true
				},
				success: function(data) {
					if(data.status) {
						 location.href="#"
					}
				},
				dataType: "json"
			})
			}
		}
	}
})

function orderLogin() {
	var list;
	$.ajax({
		url: "http://114.55.145.243:8080/liantu/Login/UsersServlet/loginUserById",
		//url:"http://localhost:8080/javaproject/Login",
		async: false,
		xhrFields: {
			withCredentials: true
		},
		success: function(data) {
			if(data.data) {
				$("#logining").css("width", "130px");
				$("#logining").prop("href", "member_info.html")
				$("#logining").html(data.data.user_tel);
				list = data.data
			}
		},
		dataType: "json"
	})
	return list
}
//
//function Dingdan() {
//	var dlist;
//	var status;
//	var uid = $("#uid").html()
//	$.ajax({
//		url: "http://114.55.145.243:8080/liantu/Login/UsersServlet/getUserById",
//		xhrFields: {
//			withCredentials: true
//		},
//		async: false,
//		data: {
//			user_id: uid
//		},
//		success: function(data) {
//			return getGuiOrder(uid)
//			return getOrder(uid)
//			}
//		},
//		dataType: "json"
//	})
//
//	
//}

function getOrder(uid) {
	var uid = $("#uid").html()
	var olist;
	$.ajax({
		url: "http://114.55.145.243:8080/liantu/OrderServlet/selectOrderListByUid",
		xhrFields: {
			withCredentials: true
		},
		async: false,
		data: {
			"order_user": uid
		},
		success: function(data) {
			if(data.status) {
				olist = data.data
			}

		},
		dataType: "json"
	})
	return olist
}

function getGuiOrder(gid){
	var uid = $("#uid").html()
	var olist;
	$.ajax({
		url: "http://114.55.145.243:8080/liantu/OrderServlet/selectOrderListByGid",
		xhrFields: {
			withCredentials: true
		},
		async: false,
		data: {
			"order_user": uid
		},
		success: function(data) {
			if(data.status) {
				olist = data.data
			}

		},
		dataType: "json"
	})
	return olist
}
